package clientApp;

import java.util.ArrayList;

import communication.client.PlayerInteractionManager;

import clientApp.utils.Game_Container;

import game.enums.EquipSlots;
import game.mechanics.Equip;
import game.mechanics.Inventory;
import game.mechanics.Item;
import game.units.Character;

/**
 * 
 * @author Gabriel
 */
@SuppressWarnings("serial")
public class InventoryMenu extends javax.swing.JPanel {

	Game_Container gameContainer;
	private Character character;
	Inventory inventory;
	ArrayList<Item> itensInInv = new ArrayList<Item>();
	ArrayList<Equip> headEquips = new ArrayList<Equip>();
	ArrayList<Equip> neckEquips = new ArrayList<Equip>();
	ArrayList<Equip> bodyEquips = new ArrayList<Equip>();
	ArrayList<Equip> shoulderEquips = new ArrayList<Equip>();
	ArrayList<Equip> mainHandEquips = new ArrayList<Equip>();
	ArrayList<Equip> offHandEquips = new ArrayList<Equip>();
	ArrayList<Equip> handsEquips = new ArrayList<Equip>();
	ArrayList<Equip> rightFingerEquips = new ArrayList<Equip>();
	ArrayList<Equip> leftFingerEquips = new ArrayList<Equip>();
	ArrayList<Equip> waistEquips = new ArrayList<Equip>();
	ArrayList<Equip> footEquips = new ArrayList<Equip>();

	/** Creates new form GameMenu */
	public InventoryMenu(Game_Container gameContainer, Character character) {
		this.gameContainer = gameContainer;
		inventory = character.getInventory();
		this.character = character;
		initWithOpenSlots();
		initComponents();
		initItensNSlots();
		refreshJCBsNList();
		getEquipedItens();
	}

	private void getEquipedItens() {
		
	}

	private void initWithOpenSlots() {
		
		ArrayList<EquipSlots> slots = new ArrayList<EquipSlots>();
		slots.add(EquipSlots.Head);
		ArrayList<EquipSlots> slots1 = new ArrayList<EquipSlots>();
		slots1.add(EquipSlots.Neck);
		ArrayList<EquipSlots> slots2 = new ArrayList<EquipSlots>();
		slots2.add(EquipSlots.Body);
		ArrayList<EquipSlots> slots3 = new ArrayList<EquipSlots>();
		slots3.add(EquipSlots.Shoulder);
		ArrayList<EquipSlots> slots4 = new ArrayList<EquipSlots>();
		slots4.add(EquipSlots.MainHand);
		ArrayList<EquipSlots> slots5 = new ArrayList<EquipSlots>();
		slots5.add(EquipSlots.OffHand);
		ArrayList<EquipSlots> slots6 = new ArrayList<EquipSlots>();
		slots6.add(EquipSlots.Hands);
		ArrayList<EquipSlots> slots7 = new ArrayList<EquipSlots>();
		slots7.add(EquipSlots.RightFinger);
		ArrayList<EquipSlots> slots8 = new ArrayList<EquipSlots>();
		slots8.add(EquipSlots.LeftFinger);
		ArrayList<EquipSlots> slots9 = new ArrayList<EquipSlots>();
		slots9.add(EquipSlots.Waist);
		ArrayList<EquipSlots> slots10 = new ArrayList<EquipSlots>();
		slots10.add(EquipSlots.Foot);		
		headEquips.add(new Equip("empty slot", " ", 0, slots, null, 0, null, 0, 0));		
		neckEquips.add(new Equip("empty slot", " ", 0, slots1, null, 0, null, 0, 0));		
		bodyEquips.add(new Equip("empty slot", " ", 0, slots2, null, 0, null, 0, 0));
		shoulderEquips.add(new Equip("empty slot", " ", 0, slots3, null, 0, null, 0, 0));
		mainHandEquips.add(new Equip("empty slot", " ", 0, slots4, null, 0, null, 0, 0));
		offHandEquips.add(new Equip("empty slot", " ", 0, slots5, null, 0, null, 0, 0));
		handsEquips.add(new Equip("empty slot", " ", 0, slots6, null, 0, null, 0, 0));
		rightFingerEquips.add(new Equip("empty slot", " ", 0, slots7, null, 0, null, 0, 0));
		leftFingerEquips.add(new Equip("empty slot", " ", 0, slots8, null, 0, null, 0, 0));
		waistEquips.add(new Equip("empty slot", " ", 0, slots9, null, 0, null, 0, 0));
		footEquips.add(new Equip("empty slot", " ", 0, slots10, null, 0, null, 0, 0));
	}

	public void refreshJCBsNList() {
		jCBHead = getRefreshedComboBoxModel(jCBHead, EquipSlots.Head,headEquips);
		jCBBody = getRefreshedComboBoxModel(jCBBody, EquipSlots.Body,bodyEquips);
		jCBNeck = getRefreshedComboBoxModel(jCBNeck, EquipSlots.Neck, neckEquips);
		jCBFoot = getRefreshedComboBoxModel(jCBFoot, EquipSlots.Foot, footEquips);
		jCBHands = getRefreshedComboBoxModel(jCBHands, EquipSlots.Hands, handsEquips);
		jCBNeck = getRefreshedComboBoxModel(jCBNeck, EquipSlots.Neck, neckEquips);
		jCBLeftFinger = getRefreshedComboBoxModel(jCBLeftFinger, EquipSlots.LeftFinger, leftFingerEquips);
		jCBMainHand = getRefreshedComboBoxModel(jCBMainHand, EquipSlots.MainHand, mainHandEquips);
		jCBOffHand = getRefreshedComboBoxModel(jCBOffHand, EquipSlots.OffHand, offHandEquips);
		jCBRightFinger = getRefreshedComboBoxModel(jCBRightFinger, EquipSlots.RightFinger, rightFingerEquips);
		jCBShoulder = getRefreshedComboBoxModel(jCBShoulder, EquipSlots.Shoulder, shoulderEquips);
		jCBWais = getRefreshedComboBoxModel(jCBWais, EquipSlots.Waist, waistEquips);
		jItemList.setModel(new javax.swing.AbstractListModel() {
			ArrayList<Item> itens = itensInInv;

			public int getSize() {
				return itens.size();
			}

			public Object getElementAt(int i) {
				return itens.get(i).getName();
			}
		});
	}
	
	private javax.swing.JComboBox getRefreshedComboBoxModel(javax.swing.JComboBox jcb, EquipSlots slot, ArrayList<Equip> equips)
	{
		int index = 0;
		jcb.setModel(new javax.swing.DefaultComboBoxModel());
		for (int i = 0; i < equips.size(); i++) {
			jcb.addItem(equips.get(i).getName());
			if(character.getInventory().getEquip(slot).getName().equals(equips.get(i)))
			{
				index = i;
			}
		}
		jcb.setSelectedIndex(index);
		return jcb;
	}

	public void initItensNSlots() {
		for (Item item : character.getInventory().getItens()) {
			if (item instanceof Equip) {
				Equip equip = (Equip) item;
				if (inventory.evaluateRequirements(equip, character.getFeats())) {
					for (EquipSlots slot : equip.getSlots()) {
						switch (slot) {
						case Head:
							headEquips.add(equip);
							break;
						case Neck:
							neckEquips.add(equip);
							break;
						case Body:
							bodyEquips.add(equip);
							break;
						case Shoulder:
							shoulderEquips.add(equip);
							break;
						case MainHand:
							mainHandEquips.add(equip);
							break;
						case OffHand:
							offHandEquips.add(equip);
							break;
						case Hands:
							handsEquips.add(equip);
							break;
						case RightFinger:
							rightFingerEquips.add(equip);
							break;
						case LeftFinger:
							leftFingerEquips.add(equip);
							break;
						case Waist:
							waistEquips.add(equip);
							break;
						case Foot:
							footEquips.add(equip);
							break;
						default:
							break;
						}
					}
				}
			} else {
				itensInInv.add(item);
			}
		}
	}

	private void initComponents() {

		jButton1 = new javax.swing.JButton();
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		jMenu3 = new javax.swing.JMenu();
		jMenuItem1 = new javax.swing.JMenuItem();
		jLabel1 = new javax.swing.JLabel();
		jSeparator1 = new javax.swing.JSeparator();
		jSeparator2 = new javax.swing.JSeparator();
		jPItens = new javax.swing.JPanel();
		jScrollPane1 = new javax.swing.JScrollPane();
		jItemList = new javax.swing.JList();
		jBViewItem = new javax.swing.JButton();
		jBDropItem = new javax.swing.JButton();
		jScrollPane2 = new javax.swing.JScrollPane();
		jTAItemDescription = new javax.swing.JTextArea();
		jLabel2 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jCBNeck = new javax.swing.JComboBox();
		jCBShoulder = new javax.swing.JComboBox();
		jCBHead = new javax.swing.JComboBox();
		jLabel5 = new javax.swing.JLabel();
		jCBBody = new javax.swing.JComboBox();
		jCBMainHand = new javax.swing.JComboBox();
		jLabel6 = new javax.swing.JLabel();
		jCBOffHand = new javax.swing.JComboBox();
		jLabel7 = new javax.swing.JLabel();
		jCBRightFinger = new javax.swing.JComboBox();
		jLabel8 = new javax.swing.JLabel();
		jCBLeftFinger = new javax.swing.JComboBox();
		jLabel9 = new javax.swing.JLabel();
		jCBHands = new javax.swing.JComboBox();
		jLabel10 = new javax.swing.JLabel();
		jCBWais = new javax.swing.JComboBox();
		jLabel11 = new javax.swing.JLabel();
		jCBFoot = new javax.swing.JComboBox();
		jLabel12 = new javax.swing.JLabel();

		jButton1.setText("jButton1");

		setBackground(new java.awt.Color(0, 0, 102));
		setBorder(javax.swing.BorderFactory.createEtchedBorder(
				javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(255,
						255, 255), new java.awt.Color(204, 204, 204)));
		setPreferredSize(new java.awt.Dimension(585, 488));

		jMenu1.setText("Main Menu");
		jMenuBar1.add(jMenu1);

		jMenu3.setText("Character");

		jMenuItem1.setText("jMenuItem1");
		jMenu3.add(jMenuItem1);

		jMenuBar1.add(jMenu3);

		jLabel1.setFont(new java.awt.Font("Tahoma", 0, 28));
		jLabel1.setForeground(new java.awt.Color(255, 255, 255));
		jLabel1.setText("Inventory");

		jPItens.setBackground(new java.awt.Color(0, 0, 102));
		jPItens.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(
				255, 255, 255), 2, true));
		jPItens.setForeground(new java.awt.Color(255, 255, 255));

		jItemList.setBackground(new java.awt.Color(0, 0, 102));
		jItemList.setFont(new java.awt.Font("Tahoma", 0, 12));
		jItemList.setForeground(new java.awt.Color(255, 255, 255));
		jItemList.setModel(new javax.swing.AbstractListModel() {
			ArrayList<Item> itens = itensInInv;

			public int getSize() {
				return itens.size();
			}

			public Object getElementAt(int i) {
				return itens.get(i);
			}
		});
		jItemList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
		jScrollPane1.setViewportView(jItemList);

		jBViewItem.setText("View Item");
		jBViewItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jBViewItemActionPerformed(evt);
			}
		});
		
		jBDropItem.setText("Drop Item");
		jBDropItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jBDropItemActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPItensLayout = new javax.swing.GroupLayout(
				jPItens);
		jPItens.setLayout(jPItensLayout);
		jPItensLayout
				.setHorizontalGroup(jPItensLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPItensLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPItensLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																jBDropItem,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																161,
																Short.MAX_VALUE)
														.addComponent(
																jBViewItem,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																161,
																Short.MAX_VALUE)
														.addComponent(
																jScrollPane1,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																161,
																Short.MAX_VALUE))
										.addContainerGap()));
		jPItensLayout.setVerticalGroup(jPItensLayout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				javax.swing.GroupLayout.Alignment.TRAILING,
				jPItensLayout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(jScrollPane1,
								javax.swing.GroupLayout.DEFAULT_SIZE, 357,
								Short.MAX_VALUE).addGap(11, 11, 11)
						.addComponent(jBDropItem)
						.addContainerGap()
						.addComponent(jBViewItem)
						.addContainerGap()));

		jTAItemDescription.setBackground(new java.awt.Color(0, 0, 102));
		jTAItemDescription.setColumns(20);
		jTAItemDescription.setEditable(false);
		jTAItemDescription.setFont(new java.awt.Font("Calibri", 0, 13));
		jTAItemDescription.setForeground(new java.awt.Color(255, 255, 255));
		jTAItemDescription.setRows(5);
		jScrollPane2.setViewportView(jTAItemDescription);

		jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel2.setForeground(new java.awt.Color(240, 240, 240));
		jLabel2.setText("Main Hand");

		jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel3.setForeground(new java.awt.Color(240, 240, 240));
		jLabel3.setText("Off-Hand");

		jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel4.setForeground(new java.awt.Color(240, 240, 240));
		jLabel4.setText("Head");

		
		jCBNeck.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBNeckItemStateChanged(evt);
			}
		});

		jCBShoulder.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"Item 1", "Item 2", "Item 3", "Item 4" }));
		jCBShoulder.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBShoulderItemStateChanged(evt);
			}
		});

		
		jCBHead.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBHeadItemStateChanged(evt);
			}
		});

		jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel5.setForeground(new java.awt.Color(240, 240, 240));
		jLabel5.setText("Body");

		
		jCBBody.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBBodyItemStateChanged(evt);
			}
		});

		
		jCBMainHand.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBMainHandItemStateChanged(evt);
			}
		});

		jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel6.setForeground(new java.awt.Color(240, 240, 240));
		jLabel6.setText("Neck");

		jCBOffHand.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBOffHandItemStateChanged(evt);
			}
		});

		jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel7.setForeground(new java.awt.Color(240, 240, 240));
		jLabel7.setText("Shoulder");


		jCBRightFinger.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBRightFingerItemStateChanged(evt);
			}
		});

		jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel8.setForeground(new java.awt.Color(240, 240, 240));
		jLabel8.setText("RightFinger");

		jCBLeftFinger.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBLeftFingerItemStateChanged(evt);
			}
		});

		jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel9.setForeground(new java.awt.Color(240, 240, 240));
		jLabel9.setText("LeftFinger");


		jCBHands.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBHandsItemStateChanged(evt);
			}
		});

		jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel10.setForeground(new java.awt.Color(240, 240, 240));
		jLabel10.setText("Hands");

		jCBWais.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBWaisItemStateChanged(evt);
			}
		});

		jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel11.setForeground(new java.awt.Color(240, 240, 240));
		jLabel11.setText("Waist");


		jCBFoot.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent evt) {
				jCBFootItemStateChanged(evt);
			}
		});

		jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12));
		jLabel12.setForeground(new java.awt.Color(240, 240, 240));
		jLabel12.setText("Foot");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addComponent(
																						jSeparator2,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						578,
																						Short.MAX_VALUE)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel1)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jSeparator1,
																										javax.swing.GroupLayout.DEFAULT_SIZE,
																										455,
																										Short.MAX_VALUE)))
																.addContainerGap())
												.addGroup(
														layout.createSequentialGroup()
																.addComponent(
																		jPItens,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addGap(18, 18,
																		18)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel12)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBFoot,
																										0,
																										283,
																										Short.MAX_VALUE)
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel11)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBWais,
																										0,
																										283,
																										Short.MAX_VALUE)
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addGroup(
																														layout.createSequentialGroup()
																																.addComponent(
																																		jLabel10)
																																.addPreferredGap(
																																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																.addComponent(
																																		jCBHands,
																																		javax.swing.GroupLayout.PREFERRED_SIZE,
																																		283,
																																		javax.swing.GroupLayout.PREFERRED_SIZE))
																												.addGroup(
																														javax.swing.GroupLayout.Alignment.TRAILING,
																														layout.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.TRAILING)
																																.addGroup(
																																		javax.swing.GroupLayout.Alignment.LEADING,
																																		layout.createSequentialGroup()
																																				.addComponent(
																																						jLabel9)
																																				.addPreferredGap(
																																						javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																																				.addComponent(
																																						jCBLeftFinger,
																																						javax.swing.GroupLayout.PREFERRED_SIZE,
																																						148,
																																						javax.swing.GroupLayout.PREFERRED_SIZE))
																																.addGroup(
																																		javax.swing.GroupLayout.Alignment.LEADING,
																																		layout.createSequentialGroup()
																																				.addComponent(
																																						jLabel8)
																																				.addPreferredGap(
																																						javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																				.addComponent(
																																						jCBRightFinger,
																																						javax.swing.GroupLayout.PREFERRED_SIZE,
																																						127,
																																						javax.swing.GroupLayout.PREFERRED_SIZE))))
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel3,
																										javax.swing.GroupLayout.PREFERRED_SIZE,
																										55,
																										javax.swing.GroupLayout.PREFERRED_SIZE)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBOffHand,
																										0,
																										283,
																										Short.MAX_VALUE)
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel2)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBMainHand,
																										0,
																										283,
																										Short.MAX_VALUE)
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel7)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBShoulder,
																										0,
																										283,
																										Short.MAX_VALUE)
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel6)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBNeck,
																										0,
																										283,
																										Short.MAX_VALUE)
																								.addContainerGap())
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel5)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jCBBody,
																										javax.swing.GroupLayout.PREFERRED_SIZE,
																										279,
																										javax.swing.GroupLayout.PREFERRED_SIZE)
																								.addContainerGap())
																				.addGroup(
																						javax.swing.GroupLayout.Alignment.TRAILING,
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING)
																												.addComponent(
																														jScrollPane2,
																														javax.swing.GroupLayout.Alignment.LEADING,
																														javax.swing.GroupLayout.DEFAULT_SIZE,
																														348,
																														Short.MAX_VALUE)
																												.addGroup(
																														layout.createSequentialGroup()
																																.addComponent(
																																		jLabel4)
																																.addPreferredGap(
																																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																.addComponent(
																																		jCBHead,
																																		0,
																																		283,
																																		Short.MAX_VALUE)))
																								.addGap(37,
																										37,
																										37)))))));

		layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { jCBLeftFinger, jCBRightFinger });

		layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { jLabel10, jLabel11, jLabel12,
						jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7,
						jLabel8 });

		layout.linkSize(
				javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { jCBBody, jCBFoot, jCBHands, jCBHead,
						jCBMainHand, jCBNeck, jCBOffHand, jCBShoulder, jCBWais });

		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.TRAILING)
												.addComponent(
														jSeparator1,
														javax.swing.GroupLayout.PREFERRED_SIZE,
														10,
														javax.swing.GroupLayout.PREFERRED_SIZE)
												.addComponent(jLabel1))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addComponent(jSeparator2,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										10,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jLabel4)
																				.addComponent(
																						jCBHead,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE))
																.addGap(4, 4, 4)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBBody,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel5))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBNeck,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel6))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBShoulder,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel7))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jLabel2)
																				.addComponent(
																						jCBMainHand,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jLabel3)
																				.addComponent(
																						jCBOffHand,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBRightFinger,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel8))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING)
																				.addComponent(
																						jLabel9)
																				.addComponent(
																						jCBLeftFinger,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBHands,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel10))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBWais,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel11))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																				.addComponent(
																						jCBFoot,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jLabel12))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																.addComponent(
																		jScrollPane2,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		128,
																		Short.MAX_VALUE))
												.addComponent(
														jPItens,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														Short.MAX_VALUE))
								.addContainerGap()));
	}// </editor-fold>//GEN-END:initComponents

	private void jCBHeadItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBHeadItemStateChanged
		// TODO add your handling code here:
		jCBHead.getSelectedIndex();
	}// GEN-LAST:event_jCBHeadItemStateChanged

	private void jCBBodyItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBBodyItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBBodyItemStateChanged

	private void jCBNeckItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBNeckItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBNeckItemStateChanged

	private void jCBShoulderItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBShoulderItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBShoulderItemStateChanged

	private void jCBMainHandItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBMainHandItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBMainHandItemStateChanged

	private void jCBOffHandItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBOffHandItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBOffHandItemStateChanged

	private void jCBRightFingerItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBRightFingerItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBRightFingerItemStateChanged

	private void jCBLeftFingerItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBLeftFingerItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBLeftFingerItemStateChanged

	private void jCBHandsItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBHandsItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBHandsItemStateChanged

	private void jCBWaisItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBWaisItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBWaisItemStateChanged

	private void jCBFootItemStateChanged(java.awt.event.ItemEvent evt) {// GEN-FIRST:event_jCBFootItemStateChanged
		// TODO add your handling code here:
	}// GEN-LAST:event_jCBFootItemStateChanged

	private void jBViewItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jBViewItemActionPerformed
		if(jItemList.getSelectedIndex() >=0)
		{
			jTAItemDescription.setText(itensInInv.get(jItemList.getSelectedIndex()).getDescription());
		}
	}
	private void jBDropItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jBViewItemActionPerformed
		if(jItemList.getSelectedIndex() >=0)
		{
			int index = jItemList.getSelectedIndex();
			Item item = itensInInv.get(index);
			if (gameContainer.isPlayer) {
				PlayerInteractionManager player = gameContainer.player;
				player.dropItemOnMap(item);
				itensInInv.remove(item);
				character.getInventory().getItens().remove(item);
				jItemList.setModel(new javax.swing.AbstractListModel() {
					ArrayList<Item> itens = itensInInv;

					public int getSize() {
						return itens.size();
					}

					public Object getElementAt(int i) {
						return itens.get(i);
					}
				});
			}
		}
	}// GEN-LAST:event_jBViewItemActionPerformed

	/**
	 * @param args
	 *            the command line arguments
	 */

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton jBViewItem;
	private javax.swing.JButton jBDropItem;
	private javax.swing.JButton jButton1;
	private javax.swing.JComboBox jCBBody;
	private javax.swing.JComboBox jCBFoot;
	private javax.swing.JComboBox jCBHands;
	private javax.swing.JComboBox jCBHead;
	private javax.swing.JComboBox jCBLeftFinger;
	private javax.swing.JComboBox jCBMainHand;
	private javax.swing.JComboBox jCBNeck;
	private javax.swing.JComboBox jCBOffHand;
	private javax.swing.JComboBox jCBRightFinger;
	private javax.swing.JComboBox jCBShoulder;
	private javax.swing.JComboBox jCBWais;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel10;
	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel12;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JList jItemList;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenu jMenu3;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JMenuItem jMenuItem1;
	private javax.swing.JPanel jPItens;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane2;
	private javax.swing.JSeparator jSeparator1;
	private javax.swing.JSeparator jSeparator2;
	private javax.swing.JTextArea jTAItemDescription;
}
